package com.pym.bs.controller;

import com.pym.bs.dto.DemosDTO;
import com.pym.bs.service.DemosService;
import com.pym.bs.utils.Pageable;
import com.pym.bs.utils.ResultVOUtils;
import com.pym.bs.vo.PageVO;
import com.pym.bs.vo.ResultVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "api/demos")
public class DemosController {

    @Resource
    private DemosService demosService;

    @RequestMapping(value = "/list")
    public ResultVO<DemosDTO> list(DemosDTO demosDTO, Pageable pageable) {
        PageVO<DemosDTO> list = demosService.list(demosDTO, pageable);
        return ResultVOUtils.success(list);
    }

    @RequestMapping(value = "/del")
    public ResultVO<DemosDTO> del(Integer id) {
        return demosService.del(id);
    }

    @RequestMapping(value = "/edit")
    public ResultVO<DemosDTO> edit(DemosDTO demosDTO) {
        return demosService.edit(demosDTO);
    }
}
